package com.base.tree;

public enum TreeEventType {
	/**
	 * 单击事件
	 */
	click(0),
	
	/**
	 * 双击事件
	 */
	doubleClick(1),
	
	/**
	 * 鼠标移入事件
	 */
	mouseOver(2),
	
	/**
	 * 鼠标移出事件
	 */
	mouseOut(3),
	
	/**
	 * 鼠标按钮按下
	 */
	mouseDown(4),
	
	/**
	 * 鼠标按钮释放
	 */
	mouseUp(5);
	
	private int value;
	
	private TreeEventType(int value){
		this.value = value;
	}
	
	/**
	 * 获取事件类型值
	 * @return 事件类型值
	 */
	public int getValue() {
		return this.value;
	}
	
	@Override
	public String toString() {
		switch (this) {
		case click:
			return "onclick";
		case doubleClick:
			return "ondblclick";
		case mouseOver:
			return "onmouseover";
		case mouseOut:
			return "onmouseout";
		case mouseDown:
			return "onmousedown";
		case mouseUp:
			return "onmouseup";
		default:
			return super.toString();
		}
	}
	
	
	/**
	 * 获取指定事件类型
	 * @param value 事件类型值
	 * @return 事件类型
	 */
	public static TreeEventType getType(int value){
		for (TreeEventType type : values()) {
			if(value == type.getValue()){
				return type;
			}
		}
		return click;
	}
}
